package com.ruoyi.web.controller.production.greenhousefilm;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.production.domain.greenhousefilm.GreenhousefilmApplyTemporary;
import com.ruoyi.production.service.greenhousefilm.IGreenhousefilmApplyTemporaryService;
import io.netty.util.internal.UnstableApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 棚膜临时申请Controller
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@RestController
@RequestMapping("/greenhousefilm/applyTemporary")
@Api(value = "棚膜临时申请",tags = "棚膜临时申请相关API")
public class GreenhousefilmApplyTemporaryController extends BaseController
{
    @Autowired
    private IGreenhousefilmApplyTemporaryService greenhousefilmApplyTemporaryService;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询棚膜临时申请列表
     */
    @PreAuthorize("@ss.hasPermi('greenhousefilm:applyTemporary:list')")
    @GetMapping("/list")
    @ApiOperation("获取棚膜临时申请列表")
    @ApiImplicitParam(name = "greenhousefilmApplyTemporary", value = "棚膜临时申请实体", paramType = "body", dataType = "GreenhousefilmApplyTemporary")
    public TableDataInfo list(GreenhousefilmApplyTemporary greenhousefilmApplyTemporary)
    {
        startPage();
        List<GreenhousefilmApplyTemporary> list = greenhousefilmApplyTemporaryService.selectGreenhousefilmApplyTemporaryList(greenhousefilmApplyTemporary);
        return getDataTable(list);
    }

    /**
     * 导出棚膜临时申请列表
     */
    @PreAuthorize("@ss.hasPermi('greenhousefilm:applyTemporary:export')")
    @Log(title = "棚膜临时申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出棚膜临时申请数据")
    @ApiImplicitParam(name = "greenhousefilmApplyTemporary", value = "棚膜临时申请实体", paramType = "body", dataType = "GreenhousefilmApplyTemporary")
    public AjaxResult export(GreenhousefilmApplyTemporary greenhousefilmApplyTemporary)
    {
        List<GreenhousefilmApplyTemporary> list = greenhousefilmApplyTemporaryService.selectGreenhousefilmApplyTemporaryList(greenhousefilmApplyTemporary);
        ExcelUtil<GreenhousefilmApplyTemporary> util = new ExcelUtil<GreenhousefilmApplyTemporary>(GreenhousefilmApplyTemporary.class);
        return util.exportExcel(list, "棚膜临时申请数据");
    }

    /**
     * 获取棚膜临时申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('greenhousefilm:applyTemporary:query')")
    @GetMapping(value = "/{greenhousefilmApplyTemporaryId}")
    @ApiOperation("获取棚膜临时申请详细信息")
    @ApiImplicitParam(name = "greenhousefilmApplyTemporaryId", value = "棚膜临时申请主键", paramType = "path", dataType = "Long")
    public AjaxResult getInfo(@PathVariable("greenhousefilmApplyTemporaryId") Long greenhousefilmApplyTemporaryId)
    {
        return AjaxResult.success(greenhousefilmApplyTemporaryService.selectGreenhousefilmApplyTemporaryById(greenhousefilmApplyTemporaryId));
    }

    /**
     * 新增棚膜临时申请
     */
    @PreAuthorize("@ss.hasPermi('greenhousefilm:applyTemporary:add')")
    @Log(title = "棚膜临时申请", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增棚膜临时申请信息")
    @ApiImplicitParam(name = "greenhousefilmApplyTemporary", value = "棚膜临时申请实体类", paramType = "body", dataType = "GreenhousefilmApplyTemporary")
    public AjaxResult add(@RequestBody GreenhousefilmApplyTemporary greenhousefilmApplyTemporary)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        greenhousefilmApplyTemporary.setUserId(loginUser.getUser().getUserId());
        return toAjax(greenhousefilmApplyTemporaryService.insertGreenhousefilmApplyTemporary(greenhousefilmApplyTemporary));
    }

    /**
     * 修改棚膜临时申请
     */
    @PreAuthorize("@ss.hasPermi('greenhousefilm:applyTemporary:edit')")
    @Log(title = "棚膜临时申请", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改棚膜临时申请信息")
    @ApiImplicitParam(name = "greenhousefilmApplyTemporary", value = "棚膜临时申请实体类", paramType = "body", dataType = "GreenhousefilmApplyTemporary")
    public AjaxResult edit(@RequestBody GreenhousefilmApplyTemporary greenhousefilmApplyTemporary)
    {
        return toAjax(greenhousefilmApplyTemporaryService.updateGreenhousefilmApplyTemporary(greenhousefilmApplyTemporary));
    }

    /**
     * 删除棚膜临时申请
     */
    @PreAuthorize("@ss.hasPermi('greenhousefilm:applyTemporary:remove')")
    @Log(title = "棚膜临时申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{greenhousefilmApplyTemporaryIds}")
    @ApiOperation("删除棚膜临时申请信息")
    @ApiImplicitParam(name = "greenhousefilmApplyTemporaryIds", value = "棚膜临时申请主键数组", paramType = "path", dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] greenhousefilmApplyTemporaryIds)
    {
        return toAjax(greenhousefilmApplyTemporaryService.deleteGreenhousefilmApplyTemporaryByIds(greenhousefilmApplyTemporaryIds));
    }
}
